package com.pig4cloud.pig.village.section.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pig4cloud.pig.village.api.dto.SectionSelect;
import com.pig4cloud.pig.village.api.entity.Section;
import com.pig4cloud.pig.village.section.mapper.SectionMapper;
import com.pig4cloud.pig.village.section.service.ISectionService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author Allen.Xie
 * @date 2022/3/15
 */
@Service
@Slf4j
public class SectionServiceImpl extends ServiceImpl<SectionMapper, Section> implements ISectionService {
	@Override
	public List<SectionSelect> listAllSelect() {
		List<Section> list = super.list();
		List<SectionSelect> result = list.stream().map(e -> {
			SectionSelect vo = new SectionSelect();
			vo.setId(e.getId());
			vo.setCode(e.getSectionCode());
			vo.setName(e.getSectionName());
			return vo;
		}).collect(Collectors.toList());
		return result;
	}
}
